//
//  UIScrollView+uitls.m
//  storeapp
//
//  Created by huangyi on 13-3-14.
//  Copyright (c) 2013年 ios. All rights reserved.
//

#import "UIScrollView+uitls.h"

@implementation UIScrollView (uitls)

-(void)contentSizeToAuto{
    int start=0;
    start+=self.showsHorizontalScrollIndicator;
    start+=self.showsVerticalScrollIndicator;
    int width=0;
    int height=0;
    for (int i=start; i<self.subviews.count; i++) {
        UIView *v=self.subviews[i];
        width=MAX(width, CGRectGetMaxX(v.frame));
        height=MAX(height, CGRectGetMaxY(v.frame));
    }
    self.contentSize=CGSizeMake(width, height);
}

-(void)scrollToTopAnimated:(BOOL)animate{
    [self scrollRectToVisible:CGRectMake(0, 0, 1, 1) animated:animate];
}
//-(void)scrollToPosition:(CGPoint)point animated:animate{
//    [self scrollRectToVisible:CGRectMake(point.x, point.y, 1, 1) animated:animate];
//}

@end
